package com.deyuanyun.pic.pipe.controller.vo;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.util.StringUtils;
import com.deyuanyun.pic.common.util.format.DateFormat;
import com.deyuanyun.pic.common.util.format.NumberFormat;
import com.deyuanyun.pic.pipe.domain.Tee;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.util.ArrayList;
import java.util.List;

/**
 * 三通信息表
 */
public class TeeVO extends BaseVO<Tee> {

    // 管道名称
    private String pipeLineName;
    // 三通编号
    private String teeNumber;
    // 上游环焊缝焊接编号
    private String ugwwId;
    // 下游环焊缝焊接编号
    private String dgwwId;
    // 绝对距离(m)
    private String mileage;
    // 相对最近参考点
    private String reference;
    // 相对最近参考点距离(m)
    private String referenceDistance;
    // 三通类型
    private String teeType;
    // 三通材质
    private String teeMaterial;
    // 是否有栅栏：0:否；1:是
    private String scraperbarind;
    // 三通尺寸（mm）外链接
    private String teeSize;
    // 支线直径（mm）
    private String branchDiameter;
    // 支线壁厚（mm）
    private String branchWallThickness;
    // 出口直径（mm）外链接
    private String outletDiameter;
    // 出口壁厚(mm)
    private String outletWallThickness;
    // 出口连接方式
    private String outletConnectionType;
    // 压力等级（MPa）
    private String pressureRating;
    // 生产厂家
    private String manufacturer;
    // 生产日期
    private String manufactureddate;
    // 链接GIS结果表
    private String gisId;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getTeeNumber() {
        return teeNumber;
    }

    public void setTeeNumber(String teeNumber) {
        this.teeNumber = teeNumber;
    }

    public String getUgwwId() {
        return ugwwId;
    }

    public void setUgwwId(String ugwwId) {
        this.ugwwId = ugwwId;
    }

    public String getDgwwId() {
        return dgwwId;
    }

    public void setDgwwId(String dgwwId) {
        this.dgwwId = dgwwId;
    }

    public String getMileage() {
        return mileage;
    }

    public void setMileage(String mileage) {
        this.mileage = mileage;
    }

    public String getReference() {
        return reference;
    }

    public void setReference(String reference) {
        this.reference = reference;
    }

    public String getReferenceDistance() {
        return referenceDistance;
    }

    public void setReferenceDistance(String referenceDistance) {
        this.referenceDistance = referenceDistance;
    }

    public String getTeeType() {
        return teeType;
    }

    public void setTeeType(String teeType) {
        this.teeType = teeType;
    }

    public String getTeeMaterial() {
        return teeMaterial;
    }

    public void setTeeMaterial(String teeMaterial) {
        this.teeMaterial = teeMaterial;
    }

    public String getScraperbarind() {
        return scraperbarind;
    }

    public void setScraperbarind(String scraperbarind) {
        this.scraperbarind = scraperbarind;
    }

    public String getTeeSize() {
        return teeSize;
    }

    public void setTeeSize(String teeSize) {
        this.teeSize = teeSize;
    }

    public String getBranchDiameter() {
        return branchDiameter;
    }

    public void setBranchDiameter(String branchDiameter) {
        this.branchDiameter = branchDiameter;
    }

    public String getBranchWallThickness() {
        return branchWallThickness;
    }

    public void setBranchWallThickness(String branchWallThickness) {
        this.branchWallThickness = branchWallThickness;
    }

    public String getOutletDiameter() {
        return outletDiameter;
    }

    public void setOutletDiameter(String outletDiameter) {
        this.outletDiameter = outletDiameter;
    }

    public String getOutletWallThickness() {
        return outletWallThickness;
    }

    public void setOutletWallThickness(String outletWallThickness) {
        this.outletWallThickness = outletWallThickness;
    }

    public String getOutletConnectionType() {
        return outletConnectionType;
    }

    public void setOutletConnectionType(String outletConnectionType) {
        this.outletConnectionType = outletConnectionType;
    }

    public String getPressureRating() {
        return pressureRating;
    }

    public void setPressureRating(String pressureRating) {
        this.pressureRating = pressureRating;
    }

    public String getManufacturer() {
        return manufacturer;
    }

    public void setManufacturer(String manufacturer) {
        this.manufacturer = manufacturer;
    }

    public String getManufactureddate() {
        return manufactureddate;
    }

    public void setManufactureddate(String manufactureddate) {
        this.manufactureddate = manufactureddate;
    }

    public String getGisId() {
        return gisId;
    }

    public void setGisId(String gisId) {
        this.gisId = gisId;
    }

    public void fromDomain(Tee domain) {

        if (ObjectUtil.isEmptyAll(domain)) {
            return;
        }
        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 三通编号
        this.teeNumber = domain.getTeeNumber();
        // 上游环焊缝焊接编号
        this.ugwwId = domain.getUgwwId();
        // 下游环焊缝焊接编号
        this.dgwwId = domain.getDgwwId();
        // 绝对距离(m)
        this.mileage = NumberFormat.format(domain.getMileage(), NumberFormat.FMT_PLACES3);
        // 相对最近参考点
        this.reference = domain.getReference();
        // 相对最近参考点距离(m)
        this.referenceDistance = NumberFormat.format(domain.getReferenceDistance(), NumberFormat.FMT_PLACES3);
        // 三通类型
        this.teeType = CodeUtil.getName(domain.getTeeType());
        // 三通材质
        this.teeMaterial = CodeUtil.getName(domain.getTeeMaterial());
        // 是否有栅栏：0:否；1:是
        this.scraperbarind = convert(domain.getScraperbarind());
        // 三通尺寸（mm）
        this.teeSize = domain.getTeeSize();
        // 支线直径（mm）
        this.branchDiameter = CodeUtil.getName(domain.getBranchDiameter());
        // 支线壁厚（mm）
        this.branchWallThickness = NumberFormat.format(domain.getBranchWallThickness());
        // 出口直径（mm）
        this.outletDiameter = CodeUtil.getName(domain.getOutletDiameter());
        // 出口壁厚(mm)
        this.outletWallThickness = NumberFormat.format(domain.getOutletWallThickness());
        // 出口连接方式
        this.outletConnectionType = CodeUtil.getName(domain.getOutletConnectionType());
        // 压力等级（MPa）
        this.pressureRating = NumberFormat.format(domain.getPressureRating());
        // 生产厂家
        this.manufacturer = domain.getManufacturer();
        // 生产日期
        this.manufactureddate = DateFormat.format(domain.getManufactureddate());
        // gis地址
        this.gisId = domain.getGisId();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordtime(), domain.getCreateRemark());
    }

    public Page<TeeVO> fromDomainList(Page<Tee> domainList) {
        Page<TeeVO> list = new Page<TeeVO>();
        for (Tee tee : domainList) {
            TeeVO teeVO = new TeeVO();
            teeVO.fromDomain(tee);
            list.add(teeVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }
}